'''
Created on 31/07/2011

@author: Digao
'''
def toInt(arg):
    return int(arg)

def toStr(a,b):
    return str(a)+' '+str(b)

keyb = {'a':'2','b':'22','c':'222','d':'3','e':'33','f':'333','g':'4','h':'44','i':'444',
        'j':'5','k':'55','l':'555','m':'6','n':'66','o':'666','p':'7','q':'77','r':'777','s':'7777',
        't':'8','u':'88','v':'888','w':'9','x':'99','y':'999','z':'9999',' ':'0'}

input = open('input.in')
CASES = int(input.readline())
for case in range(1,CASES+1):
    phrase = input.readline().strip('\n')
    sequence=''
    for ch in phrase:
        num = keyb[ch]
        if sequence and sequence[-1]==num[0]:
            sequence+=' '
        sequence+=num
    print 'Case #%d: %s'%(case,sequence)
    


